<?php

namespace Admin\Models\lm;

use Helpers\Main;
use Phalcon\Mvc\Model;

class basicModel extends Model
{


    public function beforeCreate()
    {

        $date = date('Y-m-d H:i:s', time());
        $id   = Main::getLoginUserInfo('userId');
        if (property_exists($this, 'tCreateDate')) {
            $this->tCreateDate = $date;
        }
        if (property_exists($this, 'iCreateUserId')) {
            $this->iCreateUserId = $id;
        }
        if (property_exists($this, 'tLastModifyDate')) {
            $this->tLastModifyDate = $date;
        }
        if (property_exists($this, 'iLastModifyUserId')) {
            $this->iLastModifyUserId = $id;
        }
    }

    public function beforeUpdate()
    {
        $date = date('Y-m-d H:i:s', time());
        $id   = Main::getLoginUserInfo('userId');
        if (property_exists($this, 'tLastModifyDate')) {
            $this->tLastModifyDate = $date;
        }
        if (property_exists($this, 'iLastModifyUserId')) {
            $this->iLastModifyUserId = $id;
        }
    }

}
